|
RAIS
3.2
|
00001 using System; 00002 using System.Collections.Generic; 00003 using System.Data.SqlClient; 00004 using System.Text; 00005 using NUnit.Framework; 00006 using RAIS.Common.DynamicMaskManagement; 00007 using RAIS.Common.Localization; 00008 using RAIS.Common.TableManagement; 00009 using RAIS.Common.UserManagement; 00010 using RAIS.DataAccessLayer; 00011 using Cultures = System.Collections.Generic.Dictionary<string, RAIS.Common.Localization.Culture>; 00012 using TableGroups = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.TableGroup>; 00013 using Tables = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.Table>; 00014 00015 namespace RAIS.DataAccessLayerTest 00016 { 00017 public static class TestUtilities 00018 { 00019 #region Create Objects Utilities 00020 public static FunctionRole NewFunctionRoleObject(int i) 00021 { 00022 FunctionRole functionRole = new FunctionRole(); 00023 functionRole.Name = "Test Functional Role " + i.ToString(); 00024 functionRole.Validation = FunctionRole.ValidationType.NeedsValidation; 00025 00026 return functionRole; 00027 } 00028 00029 public static DataRole NewDataRoleObject(int i) 00030 { 00031 DataRole dataRole = new DataRole(); 00032 dataRole.Name = "Test Data Role " + i.ToString(); 00033 00034 return dataRole; 00035 } 00036 00037 public static UserData NewUserObject(int i, FunctionRole functionRole, DataRole dataRole) 00038 { 00039 /*UserData user = new UserData(); 00040 user.Name = "Test Complete Name " + i.ToString(); 00041 user.Login = "testLogin" + i.ToString(); 00042 user.Password = "testPassword" + i.ToString(); 00043 user.CompleteName = user.Name; 00044 user.Email = "test@email" + i.ToString() + ".com"; 00045 user.Locked = false; 00046 user.TypeText = "Public Body"; 00047 user.FunctionalRole = functionRole; 00048 user.DataRole = dataRole; 00049 user.DataRoleType = (int)UserData.DataRoleIndication.DataRole; 00050 */ 00051 return null; 00052 } 00053 00054 public static FunctionRoleAttribute NewTestFunctionRoleAttribute(int i) 00055 { 00056 FunctionRoleAttribute functionRoleAttribute = new FunctionRoleAttribute(); 00057 functionRoleAttribute.Category = NewTestCategoryWithSave(1); 00058 functionRoleAttribute.Subcategory = NewTestSubcategoryWithSave(1, functionRoleAttribute.Category); 00059 functionRoleAttribute.Mask = NewTestMaskWithSave(1, functionRoleAttribute.Category, functionRoleAttribute.Subcategory); 00060 00061 return functionRoleAttribute; 00062 } 00063 00064 public static FunctionRole NewTestFunctionRoleWithSave(int i) 00065 { 00066 bool returnStatus; 00067 string errorMessage = ""; 00068 00069 FunctionRole expectedFunctionRole = TestUtilities.NewFunctionRoleObject(i); 00070 returnStatus = UserManagement.AddFunctionRole(expectedFunctionRole.Name, ref errorMessage); 00071 if (!returnStatus) 00072 throw new Exception("Add Functional Role Error"); 00073 expectedFunctionRole = UserManagement.FunctionalRoles[expectedFunctionRole.Name]; 00074 00075 return expectedFunctionRole; 00076 } 00077 00078 public static DataRoleAttribute NewTestDataRoleAttribute(int i) 00079 { 00080 DataRoleAttribute dataRoleAttribute = new DataRoleAttribute(); 00081 dataRoleAttribute.Region = NewTestRegionWithSave(1); 00082 dataRoleAttribute.District = NewTestDistrictWithSave(1, dataRoleAttribute.Region); 00083 dataRoleAttribute.Facility = NewTestFacilityWithSave(1, dataRoleAttribute.Region, dataRoleAttribute.District); 00084 00085 return dataRoleAttribute; 00086 } 00087 00088 public static DataRole NewTestDataRoleWithSave(int i) 00089 { 00090 bool returnStatus; 00091 string errorMessage = ""; 00092 00093 DataRole expectedDataRole = TestUtilities.NewDataRoleObject(i); 00094 returnStatus = UserManagement.AddDataRole(expectedDataRole.Name, ref errorMessage); 00095 if (!returnStatus) 00096 throw new Exception("Add Data Role Error"); 00097 expectedDataRole = UserManagement.DataRoles[expectedDataRole.Name]; 00098 00099 return expectedDataRole; 00100 } 00101 00102 public static UserData NewTestUser(int i) 00103 { 00104 FunctionRole expectedFunctionRole = NewTestFunctionRoleWithSave(i); 00105 00106 DataRole expectedDataRole = NewTestDataRoleWithSave(i); 00107 00108 UserData expectedUser = TestUtilities.NewUserObject(i, expectedFunctionRole, expectedDataRole); 00109 00110 return expectedUser; 00111 } 00112 00113 public static UserData NewTestUserWithSave(int i) 00114 { 00115 bool returnStatus; 00116 string errorMessage = ""; 00117 00118 UserData expectedUser = NewTestUser(i); 00119 00120 returnStatus = UserManagement.AddUser(expectedUser, ref errorMessage); 00121 if (!returnStatus) 00122 throw new Exception("Add User Error"); 00123 00124 return expectedUser; 00125 } 00126 00127 public static Region NewTestRegionWithSave(int i) 00128 { 00129 using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00130 { 00131 string regionName = "Test Region " + i.ToString(); 00132 00133 sqlConnection.Open(); 00134 00135 using (SqlCommand sqlCommand = 00136 new SqlCommand("INSERT [Region] ([Region Name]) VALUES ('" + regionName + "')" 00137 , sqlConnection)) 00138 { 00139 sqlCommand.CommandType = System.Data.CommandType.Text; 00140 sqlCommand.ExecuteNonQuery(); 00141 } 00142 00143 Region region = UserManagement.Regions[regionName]; 00144 00145 return region; 00146 } 00147 } 00148 00149 public static District NewTestDistrictWithSave(int i, Region region) 00150 { 00151 using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00152 { 00153 string districtName = "Test District " + i.ToString(); 00154 00155 sqlConnection.Open(); 00156 00157 using (SqlCommand sqlCommand = 00158 new SqlCommand("INSERT [District] ([FK Region ID], [District Name]) VALUES (" 00159 + region.ID.ToString() 00160 + ", '" + districtName + "')" 00161 , sqlConnection)) 00162 { 00163 sqlCommand.CommandType = System.Data.CommandType.Text; 00164 sqlCommand.ExecuteNonQuery(); 00165 } 00166 00167 District district = UserManagement.GetDistrictsByRegion(region)[districtName]; 00168 00169 return district; 00170 } 00171 } 00172 00173 public static Facility NewTestFacilityWithSave(int i, Region region, District district) 00174 { 00175 using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00176 { 00177 string facilityName = "Test Facility " + i.ToString(); 00178 00179 sqlConnection.Open(); 00180 00181 using (SqlCommand sqlCommand = 00182 new SqlCommand("INSERT [Facility] " 00183 + "([Regulatory Authority Number], [Facility Name], [FK Facility Status ID], [FK Region ID], [FK District ID])" 00184 + " SELECT " 00185 + "'[Unknown]'" 00186 + ", '" + facilityName + "'" 00187 + ", [PK Facility Status ID]" 00188 + ", " + region.ID.ToString() 00189 + ", " + district.ID.ToString() 00190 + " FROM [Facility Status] WHERE [Status Name] = '[Unknown]'" 00191 , sqlConnection)) 00192 { 00193 sqlCommand.CommandType = System.Data.CommandType.Text; 00194 sqlCommand.ExecuteNonQuery(); 00195 } 00196 00197 Facility facility = UserManagement.GetFacilitiesByRegionAndDistrict(region, district)[facilityName]; 00198 00199 return facility; 00200 } 00201 } 00202 00203 public static FunctionRole.Category NewTestCategoryWithSave(int i) 00204 { 00205 using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00206 { 00207 string categoryName = "Test Category " + i.ToString(); 00208 00209 sqlConnection.Open(); 00210 00211 using (SqlCommand sqlCommand = 00212 new SqlCommand("INSERT [Category] ([Category Name], [Order]) VALUES ('" + categoryName + "', " + i.ToString() + ")" 00213 , sqlConnection)) 00214 { 00215 sqlCommand.CommandType = System.Data.CommandType.Text; 00216 sqlCommand.ExecuteNonQuery(); 00217 } 00218 00219 FunctionRole.Category category = UserManagement.FunctionalRoleCategories[categoryName]; 00220 00221 return category; 00222 } 00223 } 00224 00225 public static FunctionRole.Subcategory NewTestSubcategoryWithSave(int i, FunctionRole.Category category) 00226 { 00227 using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00228 { 00229 string subcategoryName = "Test Subcategory " + i.ToString(); 00230 00231 sqlConnection.Open(); 00232 00233 using (SqlCommand sqlCommand = 00234 new SqlCommand("INSERT [Subcategory] ([FK Category ID], [Subcategory Name], [Order], [Image Index]) VALUES (" 00235 + category.ID.ToString() 00236 + ", '" + subcategoryName + "'" 00237 + ", " + i.ToString() 00238 + ", 0" 00239 + ")" 00240 , sqlConnection)) 00241 { 00242 sqlCommand.CommandType = System.Data.CommandType.Text; 00243 sqlCommand.ExecuteNonQuery(); 00244 } 00245 00246 FunctionRole.Subcategory subcategory = UserManagement.GetFunctionalRoleSubcategories(category)[subcategoryName]; 00247 00248 return subcategory; 00249 } 00250 } 00251 00252 public static Mask NewTestMaskWithSave(int i, FunctionRole.Category category, FunctionRole.Subcategory subcategory) 00253 { 00254 using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00255 { 00256 string maskName = "Test Mask " + i.ToString(); 00257 00258 sqlConnection.Open(); 00259 00260 using (SqlCommand sqlCommand = 00261 new SqlCommand("INSERT [Mask] (" 00262 + "[Mask Name]" 00263 + ", [FK Subcategory ID]" 00264 + ", [Order]" 00265 + ", [Image Index]" 00266 + ", [Reference]" 00267 + ") VALUES (" 00268 + "'" + maskName + "'" 00269 + ", " + subcategory.ID.ToString() 00270 + ", " + i.ToString() 00271 + ", 0" 00272 + ", '" + maskName + ".aspx'" 00273 + ")" 00274 , sqlConnection)) 00275 { 00276 sqlCommand.CommandType = System.Data.CommandType.Text; 00277 sqlCommand.ExecuteNonQuery(); 00278 } 00279 00280 Mask mask = UserManagement.GetMasks(category, subcategory)[maskName]; 00281 00282 return mask; 00283 } 00284 } 00285 00286 public static Culture NewTestCultureWithSave(int i) 00287 { 00288 bool returnStatus; 00289 string errorMessage = ""; 00290 00291 Culture expectedCulture = new Culture(i); 00292 returnStatus = Localisation.AddCulture(expectedCulture, ref errorMessage); 00293 if (!returnStatus) 00294 throw new Exception("Add culture error"); 00295 00296 return expectedCulture; 00297 } 00298 00299 public static Table NewTableObject(int i) 00300 { 00301 Table table = new Table(); 00302 00303 table.Name = "Test Table " + i.ToString(); 00304 table.TypeText = "Single"; 00305 table.CustomTable = true; 00306 00307 return table; 00308 } 00309 00310 public static Table NewTestTableWithSave(int i) 00311 { 00312 /* string errorMessage = ""; 00313 string tableGroupName = "Associated Equipments"; 00314 00315 TableGroups tableGroups = TableManagement.TableGroups; 00316 TableGroup tableGroup = tableGroups[tableGroupName]; 00317 00318 Table table = NewTableObject(i); 00319 00320 if (!TableManagement.AddTable(table, tableGroup, ref errorMessage)) 00321 throw new Exception("Add Table Error");*/ 00322 00323 return null; 00324 } 00325 00326 public static Field NewTextFieldObject(int i) 00327 { 00328 return NewFieldObject(i, "Text"); 00329 } 00330 00331 public static Field NewSingleLookupFieldObject(int i) 00332 { 00333 return NewFieldObject(i, "Single Lookup"); 00334 } 00335 00336 public static Field NewLookupPlusIntegerFieldObject(int i) 00337 { 00338 return NewFieldObject(i, "Lookup Plus Integer Value"); 00339 } 00340 00341 public static Field NewFieldObject(int i, string typeText) 00342 { 00343 Field field = new Field(); 00344 field.Name = "Test Field " + i.ToString(); 00345 field.FieldPurpose = "Test Field Purpose"; 00346 field.LocalLanguageFieldName = "Тестовое поле " + i.ToString(); 00347 field.LocalLanguageFieldPurpose = "Назначение тестового поля"; 00348 field.TypeText = typeText; 00349 field.NecessityText = "Required"; 00350 field.Order = i; 00351 field.IsNameField = false; 00352 field.SystemField = false; 00353 field.VisibleOnForms = true; 00354 field.UniqueValue = false; 00355 field.NeedsTranslation = false; 00356 field.Multiline = false; 00357 field.RelatedTable = null; 00358 00359 return field; 00360 } 00361 00362 public static Table CreateSingleTable(int i, TableGroup tableGroup) 00363 { 00364 /* string errorMessage = ""; 00365 Table table = new Table(); 00366 00367 table.Name = "_Test Table " + i.ToString(); 00368 table.TypeText = "Single"; 00369 table.CustomTable = true; 00370 Assert.IsTrue(TableManagement.AddTable(table, tableGroup, ref errorMessage) 00371 , string.Format("Add table {0}", table.Name)); 00372 */ 00373 return null; 00374 } 00375 00376 public static string TestFieldName(int i) 00377 { 00378 return "Test Field " + i.ToString(); 00379 } 00380 00381 public static Field AddTextField(int i, Table table) 00382 { 00383 string errorMessage = ""; 00384 Field field = new Field(); 00385 00386 field.Name = TestFieldName(i); 00387 field.LocalLanguageFieldName = "Поле " + i.ToString(); 00388 field.FieldPurpose = "Field Purpouse"; 00389 field.LocalLanguageFieldPurpose = "Назначение поля"; 00390 field.TypeText = "Text"; 00391 field.SizeText = "Small (below 50 chars)"; 00392 field.NecessityText = "Required"; 00393 field.Order = i; 00394 field.IsNameField = true; 00395 field.SystemField = false; 00396 field.VisibleOnForms = true; 00397 field.UniqueValue = true; 00398 field.NeedsTranslation = false; 00399 field.Multiline = false; 00400 field.RelatedTable = null; 00401 Assert.IsTrue(TableManagement.AddField(table, field, ref errorMessage) 00402 , string.Format("Add field {0} to table {1}", field.Name, table.Name)); 00403 00404 if (table.Fields == null) 00405 table.Fields = new Dictionary<string, Field>(); 00406 00407 table.Fields.Add(field.Name, field); 00408 00409 return field; 00410 } 00411 00412 public static Field AddSingleLookupField(int i, Table table, Table relatedTable) 00413 { 00414 string errorMessage = ""; 00415 Field field = new Field(); 00416 00417 field.Name = "Test Field " + i.ToString(); 00418 field.LocalLanguageFieldName = "Поле " + i.ToString(); 00419 field.FieldPurpose = "Field Purpouse" + i.ToString(); 00420 field.LocalLanguageFieldPurpose = "Назначение поля" + i.ToString(); 00421 field.TypeText = "Single Lookup"; 00422 field.NecessityText = "Suggested"; 00423 field.Order = i; 00424 field.IsNameField = false; 00425 field.SystemField = false; 00426 field.VisibleOnForms = true; 00427 field.UniqueValue = false; 00428 field.NeedsTranslation = false; 00429 field.Multiline = false; 00430 field.RelatedTable = relatedTable; 00431 Assert.IsTrue(TableManagement.AddField(table, field, ref errorMessage) 00432 , string.Format("Add field {0} to table {1}", field.Name, table.Name)); 00433 00434 return field; 00435 } 00436 00437 public static Field AddLookupPlusIntegerField(int i, Table table, Table relatedTable) 00438 { 00439 string errorMessage = ""; 00440 Field field = new Field(); 00441 00442 field.Name = "Test Field " + i.ToString(); 00443 field.LocalLanguageFieldName = "Поле " + i.ToString(); 00444 field.FieldPurpose = "Field Purpouse" + i.ToString(); 00445 field.LocalLanguageFieldPurpose = "Назначение поля" + i.ToString(); 00446 field.TypeText = "Lookup Plus Integer Value"; 00447 field.NecessityText = "Required"; 00448 field.Order = i; 00449 field.IsNameField = false; 00450 field.SystemField = false; 00451 field.VisibleOnForms = true; 00452 field.UniqueValue = false; 00453 field.NeedsTranslation = false; 00454 field.Multiline = false; 00455 field.RelatedTable = relatedTable; 00456 Assert.IsTrue(TableManagement.AddField(table, field, ref errorMessage) 00457 , string.Format("Add field {0} to table {1}", field.Name, table.Name)); 00458 00459 return field; 00460 } 00461 00462 public static DynamicMask CreateSingleRowMaskWithListInDB(int i, Table table) 00463 { 00464 DynamicMask dynamicMask = new DynamicMask(); 00465 00466 dynamicMask.Name = "Test Dynamic Mask " + i.ToString(); 00467 dynamicMask.Type = DynamicMask.DynamicMaskType.SingleRowMaskWithList; 00468 dynamicMask.Table = table; 00469 00470 using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00471 { 00472 sqlConnection.Open(); 00473 00474 using (SqlCommand sqlCommand = 00475 new SqlCommand(string.Format( 00476 "INSERT [Dynamic Mask]" 00477 + " ([Dynamic Mask Name], [FK Dynamic Mask Type ID], [FK Table ID])" 00478 + " VALUES" 00479 + " ('{0}', {1}, {2})" 00480 , dynamicMask.Name, dynamicMask.TypeData.ID, dynamicMask.Table.ID) 00481 , sqlConnection)) 00482 { 00483 sqlCommand.CommandType = System.Data.CommandType.Text; 00484 try 00485 { 00486 sqlCommand.ExecuteNonQuery(); 00487 } 00488 catch (Exception ex) 00489 { 00490 throw new Exception("Add DynamicMask Error: " + ex.Message); 00491 } 00492 } 00493 } 00494 00495 return dynamicMask; 00496 } 00497 #endregion 00498 00499 #region Cleaning Utilities 00500 //public bool DeleteUser(UserData user) 00501 //{ 00502 // try 00503 // { 00504 // using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00505 // { 00506 // sqlConnection.Open(); 00507 00508 // using (SqlCommand sqlCommand = 00509 // new SqlCommand("DELETE FROM [User] WHERE [User Name] = '" + user.Login + "'" 00510 // , sqlConnection)) 00511 // { 00512 // sqlCommand.CommandType = System.Data.CommandType.Text; 00513 // sqlCommand.ExecuteNonQuery(); 00514 // } 00515 // } 00516 // return true; 00517 // } 00518 // catch 00519 // { 00520 // return false; 00521 // } 00522 //} 00523 00524 public static bool TruncateTable(string tableName) 00525 { 00526 try 00527 { 00528 using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00529 { 00530 sqlConnection.Open(); 00531 00532 using (SqlCommand sqlCommand = 00533 new SqlCommand("DELETE FROM [" + tableName + "]" 00534 , sqlConnection)) 00535 { 00536 sqlCommand.CommandType = System.Data.CommandType.Text; 00537 sqlCommand.ExecuteNonQuery(); 00538 } 00539 } 00540 return true; 00541 } 00542 catch 00543 { 00544 return false; 00545 } 00546 } 00547 00548 public static bool TruncateTableRegion() 00549 { 00550 try 00551 { 00552 using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00553 { 00554 sqlConnection.Open(); 00555 00556 using (SqlCommand sqlCommand = 00557 new SqlCommand("DELETE FROM [Region] WHERE [PK Region ID] != dbo.ufn_GetAllRegionsID()" 00558 , sqlConnection)) 00559 { 00560 sqlCommand.CommandType = System.Data.CommandType.Text; 00561 sqlCommand.ExecuteNonQuery(); 00562 } 00563 } 00564 return true; 00565 } 00566 catch 00567 { 00568 return false; 00569 } 00570 } 00571 00572 public static bool TruncateTableDistrict() 00573 { 00574 try 00575 { 00576 using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00577 { 00578 sqlConnection.Open(); 00579 00580 using (SqlCommand sqlCommand = 00581 new SqlCommand("DELETE FROM [District] WHERE [PK District ID] != dbo.ufn_GetAllDistrictsID()" 00582 , sqlConnection)) 00583 { 00584 sqlCommand.CommandType = System.Data.CommandType.Text; 00585 sqlCommand.ExecuteNonQuery(); 00586 } 00587 } 00588 return true; 00589 } 00590 catch 00591 { 00592 return false; 00593 } 00594 } 00595 00596 public static bool TruncateTableFacility() 00597 { 00598 try 00599 { 00600 using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00601 { 00602 sqlConnection.Open(); 00603 00604 using (SqlCommand sqlCommand = 00605 new SqlCommand("DELETE FROM [Facility] WHERE [PK Facility ID] != dbo.ufn_GetAllFacilitiesID()" 00606 , sqlConnection)) 00607 { 00608 sqlCommand.CommandType = System.Data.CommandType.Text; 00609 sqlCommand.ExecuteNonQuery(); 00610 } 00611 } 00612 return true; 00613 } 00614 catch 00615 { 00616 return false; 00617 } 00618 } 00619 00620 public static bool TruncateTableCategory() 00621 { 00622 try 00623 { 00624 using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00625 { 00626 sqlConnection.Open(); 00627 00628 using (SqlCommand sqlCommand = 00629 new SqlCommand("DELETE FROM [Category] WHERE [PK Category ID] != dbo.ufn_GetAllCategoriesID()" 00630 , sqlConnection)) 00631 { 00632 sqlCommand.CommandType = System.Data.CommandType.Text; 00633 sqlCommand.ExecuteNonQuery(); 00634 } 00635 } 00636 return true; 00637 } 00638 catch 00639 { 00640 return false; 00641 } 00642 } 00643 00644 public static bool TruncateTableSubcategory() 00645 { 00646 try 00647 { 00648 using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00649 { 00650 sqlConnection.Open(); 00651 00652 using (SqlCommand sqlCommand = 00653 new SqlCommand("DELETE FROM [Subcategory] WHERE [PK Subcategory ID] != dbo.ufn_GetAllSubcategoriesID()" 00654 , sqlConnection)) 00655 { 00656 sqlCommand.CommandType = System.Data.CommandType.Text; 00657 sqlCommand.ExecuteNonQuery(); 00658 } 00659 } 00660 return true; 00661 } 00662 catch 00663 { 00664 return false; 00665 } 00666 } 00667 00668 public static bool TruncateTableMask() 00669 { 00670 try 00671 { 00672 using (SqlConnection sqlConnection = new SqlConnection(DataAccessUtilities.ConnectionString)) 00673 { 00674 sqlConnection.Open(); 00675 00676 using (SqlCommand sqlCommand = 00677 new SqlCommand("DELETE FROM [Mask] WHERE [PK Mask ID] != dbo.ufn_GetAllMasksID()" 00678 , sqlConnection)) 00679 { 00680 sqlCommand.CommandType = System.Data.CommandType.Text; 00681 sqlCommand.ExecuteNonQuery(); 00682 } 00683 } 00684 return true; 00685 } 00686 catch 00687 { 00688 return false; 00689 } 00690 } 00691 00692 public static bool TruncateTables() 00693 { 00694 bool returnCode = true; 00695 00696 returnCode &= TruncateTable("User"); 00697 00698 returnCode &= TruncateTable("Functional Role Restriction"); 00699 returnCode &= TruncateTable("Functional Role"); 00700 00701 returnCode &= TruncateTable("Data Role Restriction"); 00702 returnCode &= TruncateTable("Data Role"); 00703 00704 returnCode &= TruncateTableFacility(); 00705 returnCode &= TruncateTableDistrict(); 00706 returnCode &= TruncateTableRegion(); 00707 00708 returnCode &= TruncateTableMask(); 00709 returnCode &= TruncateTableSubcategory(); 00710 returnCode &= TruncateTableCategory(); 00711 00712 return returnCode; 00713 } 00714 00715 public static bool DeleteTestCultures() 00716 { 00717 bool returnStatus = true; 00718 string errorMessage = ""; 00719 00720 Cultures cultures = Localisation.SupportedLanguages; 00721 00722 foreach (KeyValuePair<string, Culture> culturePair in cultures) 00723 if (culturePair.Key != "English") 00724 returnStatus &= Localisation.DeleteCulture(culturePair.Value, ref errorMessage); 00725 00726 return returnStatus; 00727 } 00728 00729 public static bool DeleteTestTables() 00730 { 00731 /* string errorMessage = ""; 00732 bool returnCode = true; 00733 00734 Tables tables = TableManagement.GetTablesByTableGroup(TableManagement.TableGroups["Associated Equipments"]); 00735 00736 foreach (KeyValuePair<string, Table> kvp in tables) 00737 { 00738 Table table = kvp.Value; 00739 if (table.CustomTable) 00740 returnCode &= TableManagement.RemoveTable(table, ref errorMessage); 00741 } 00742 */ 00743 return true; 00744 } 00745 00746 public static bool TruncateTablesForDynamicMaskManagementTest() 00747 { 00748 bool returnCode = true; 00749 00750 // Delete test Tables 00751 returnCode &= DeleteTestTables(); 00752 00753 // Delete Test Dynamic Masks 00754 returnCode &= TruncateTable("Dynamic Mask"); 00755 00756 return returnCode; 00757 } 00758 00759 #endregion 00760 } 00761 }